package cn.com.scooper.controller.data.xf;

import cn.com.scooper.common.resp.APIObjectJson;
import cn.com.scooper.common.resp.APIRespJson;
import cn.com.scooper.pojo.po.MineDeviceAlarmPo;
import cn.com.scooper.pojo.qo.MineDeviceAlarmClearQo;
import cn.com.scooper.pojo.qo.MineDeviceAlarmSaveQo;
import cn.com.scooper.pojo.qo.MineDeviceAlarmUpdateQo;
import cn.com.scooper.service.xf.MineDeviceAlarmService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/data/mineDeviceAlarm")
public class MineDeviceAlarmController {
    @Autowired
    private MineDeviceAlarmService mineDeviceAlarmService;

    private static final Logger logger = LoggerFactory.getLogger(MineDeviceAlarmController.class);

    /**
     * 新增报警
     *
     * @param mineDeviceAlarmSaveQo
     * @return APIRespJson
     */
    @PostMapping("/save")
    public APIRespJson save(@Valid @RequestBody MineDeviceAlarmSaveQo mineDeviceAlarmSaveQo) {
        MineDeviceAlarmPo mineDeviceAlarmPo = mineDeviceAlarmService.save(mineDeviceAlarmSaveQo);
        return new APIRespJson().setData(mineDeviceAlarmPo);
    }

    /**
     * 处置报警
     *
     * @param mineDeviceAlarmUpdateQo
     * @return
     */
    @PostMapping("/handle")
    public APIRespJson handle(@Valid @RequestBody MineDeviceAlarmUpdateQo mineDeviceAlarmUpdateQo) {
        MineDeviceAlarmPo mineDeviceAlarmPo = mineDeviceAlarmService.handle(mineDeviceAlarmUpdateQo);
        return new APIObjectJson(mineDeviceAlarmPo);
    }

    /**
     * 清楚报警
     * @param mineDeviceAlarmClearQo
     * @return
     */
    @PostMapping("/clear")
    public APIRespJson clear(@RequestBody MineDeviceAlarmClearQo mineDeviceAlarmClearQo) {
        MineDeviceAlarmPo mineDeviceAlarmPo = mineDeviceAlarmService.clear(mineDeviceAlarmClearQo);
        return new APIObjectJson(mineDeviceAlarmPo);
    }
}